package com.boarsoft.boar.agent.client.impl;

import java.util.Collections;

import com.boarsoft.boar.agent.client.LinuxController;
import com.boarsoft.boar.agent.client.ServiceController;
import com.boarsoft.boar.agent.client.pojo.Operation;
import com.boarsoft.common.Util;

/**
 * 服务脚本的控制类实现
 * 
 * @author YangLiu
 * @CreateDate 2018年3月27日 下午5:42:42
 * @version 1.0
 * 
 * @UpdateUser 修改人名称
 * @UpdateDate 2018年3月27日 下午5:42:42
 * @UpdateRemark 修改具体的内容
 */
public class SvcShell extends LinuxController<String> implements ServiceController<String> {
	
	public static final String APP_NAME = "app_name";

	public Operation get(String svrUser, String svrIp, String rpcIp, String rpcPort,
			String proxyAbsPath, String proxyRelPath, String proxyName,
			String targetAbsPath, String targetName, String appName, String operator) {
		Operation opt = new Operation();
		opt.setSvrUser(svrUser);
		opt.setSvrAddress(svrIp);
		if (Util.strIsNotEmpty(rpcIp) 
				&& Util.strIsNotEmpty(rpcPort)) {
			opt.setAgentAddress(String.format("%s:%s", rpcIp, rpcPort));
		}
		opt.setProxyAbsPath(proxyAbsPath);
		opt.setProxyRelPath(proxyRelPath);
		opt.setProxyName(proxyName);
		opt.setTargetAbsPath(targetAbsPath);
		opt.setTargetName(targetName);
		opt.setRunParams(Collections.singletonMap(APP_NAME, appName));
		return opt;
	}
	
	public Operation get(String svrUser, String svrIp,
			String proxyAbsPath, String proxyRelPath, String proxyName,
			String targetAbsPath, String targetName, String appName, String operator) {
		Operation opt = new Operation();
		opt.setSvrUser(svrUser);
		opt.setSvrAddress(svrIp);
		opt.setProxyAbsPath(proxyAbsPath);
		opt.setProxyRelPath(proxyRelPath);
		opt.setProxyName(proxyName);
		opt.setTargetAbsPath(targetAbsPath);
		opt.setTargetName(targetName);
		opt.setRunParams(Collections.singletonMap(APP_NAME, appName));
		return opt;
	}
}
